<?

if ($c = stack('name')) {


if ( $cur_interview = (int) str_safe(trim(postdata("cpn-$c-formelement"))) ) {

$DATA['questions'] = datafetch_array('db_list', array(
											  'select' => 'name, interview.id, COUNT(*) num',
											  'table' => $_tables, 
											  'where' => $_crits,
											  'group' => 'name, interview.id', 
											  'order' => 'name'));

	
}



//debug($STACK);
$_tables = 'int_interview interview , int_question quest, int_interview_int_question view_quest';
$_crits = 'interview.id = view_quest.int_interview_id AND
      	  quest.id = view_quest.questions_id AND
      	  interview.active = 1';
$_per_page = 20;
$_paging = 'page';
//dbdebug(1,1);
$DATA['objects'] = array();							
$DATA['objects'] = datafetch_array('db_list', array(
											  'select' => 'name, interview.id, COUNT(*) num',
											  'table' => $_tables, 
											  'where' => $_crits,
											  'group' => 'name, interview.id', 
											  'order' => 'name'));


//debug($DATA['objects']);


/*if ($num = datafetch('db_item', $_table, $_crit, "COUNT(*) as num")) {

	if ($num = $num['num']) {
		$DATA['paging'] = createPaging(array(
			'num' => $num, 
			'page' => param('page'), 
			'param' => $_paging, 
			'perPage' => $_per_page,
			'pagesBefore' => 4, 'pagesAfter' => 4,
			'pagesAtStart' => 4, 'pagesAtEnd' => 4,
		));		
		
		$DATA['objects'] = datafetch_array('db_list', array(
			'table' => $_table, 
			'where' => $_crit, 
			'index' => 'id', 
			'order' => 'Name',
			'limit' => $DATA['paging']['limit']
		));
	}

}*/

	
}
unstack();